<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        div {
            width: 300px;
            height: 110px;
            background-color: aquamarine;
            margin: 200px auto;
        }

        h1 {
            height: 50px;
            color: red;
            font-family: "kaiti";
            text-align: center;
        }

        input {
            width: 296px;
            height: 50px;
        }
    </style>
</head>

<body>
    <div>
        <h1></h1>
        <input type="text" name="username">
    </div>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
    $('input').blur(function(){
        let username = $('input').val();
        if($('input').val()==""){
            $('h1').text('请输入正确的名字');
            return;
        };
        $.ajax({
            type:'post',
            url:'http://localhost:3000/index',
            data:{username},
            success:(data)=>{
                if(data.statua != 200){
                    $('h1').text(`${data.msg}`);
                }else{
                    $('h1').text(`${data.msg}`);
                };  
            }
        });
    });
</script>

</html>